package com.kly.sc.api.application.controller.device.request;

import com.fqgj.common.api.ParamsObject;
import com.kly.sc.api.infras.exception.ApplicationException;
import com.kly.user.enums.PermissionTypeEnum;

import java.util.Objects;

public class PermissionOperationRequest extends ParamsObject {

    /**
     * 权限类型:1-gps 位置权限 2-通知权限
     */
    private Integer permissionType;
    /**
     * 是否给予授权：1-授予 0-不授予
     */
    private Integer grantFlag;

    @Override
    public void validate() {
        if (Objects.isNull(this.permissionType) || Objects.isNull(PermissionTypeEnum.fromType(this.permissionType))) {
            throw new ApplicationException("The parameter [permissionType] is empty or Illegal parameter" );
        }
        if (Objects.isNull(this.grantFlag)) {
            throw new ApplicationException("The parameter [grantFlag] is empty" );
        }
    }

    public Integer getPermissionType() {
        return permissionType;
    }

    public void setPermissionType(Integer permissionType) {
        this.permissionType = permissionType;
    }

    public Integer getGrantFlag() {
        return grantFlag;
    }

    public void setGrantFlag(Integer grantFlag) {
        this.grantFlag = grantFlag;
    }
}
